<template>
  <div class="issue-wrap">


    <!--发布的招聘-->
    <van-list
      v-model="loading"
      :finished="finished"
      @load="onLoad"
      class="work-van"
    >
      <work-info :itemList="workList" @openRecruit="openRecruit"></work-info>

      <div class="empty-box" v-if="workList.length == 0 && !loading">
        <img src="../../../images/empty.png" class="empty"/>
      </div>
    </van-list>


    <div class="publish-box" @click="openEdit">
      <img src="./publish.png" class="publish"/>
      <span class="publish-title">发布招聘</span>
    </div>

  </div>
</template>

<script>
  import workInfo from "../../../components/workinfo"
  import {queryIssueWork} from '../../../axios/api'
  import {setSessionStore} from "../../../config/util";

  export default {
    data() {
      return {
        workList: [],
        page: 1,
        size: 20,
        loading: false,
        finished: false,
        identity: ""
      }
    },
    mounted() {
      this.identity = this.$store.getters.getIdentity;
    },
    methods: {
      onLoad() {
        if (!this.timer) {
          this.timer = setTimeout(() => {
            this.getWorkList();
            this.timer = null;
          }, 500)
        }
      },
      getWorkList() {//查询招聘列表
        const params = {
          "page": this.page,
          "size": this.size,
          "sgin": this.identity
        };

        queryIssueWork(params).then(res => {
          if (res.code == 0) {
            if (res.data != null && res.data.length > 0) {
              console.log(JSON.stringify(res.data));
              this.workList = this.workList.concat(res.data);
              //加载状态结束
              this.loading = false;
              this.page++;
            } else {
              this.loading = false;
              if (this.workList.length >= res.data.length) {
                this.finished = true;
              }
            }
          }
        });
      },
      openRecruit(id) {//招聘詳情
        this.$router.push({path: "/workpreview", query: {"issueId": id, "type": 2}});
      },
      openEdit() {//编辑
        this.$router.push({path: "/workedit", query: {"type": 1}});
      }
    },
    components: {
      workInfo
    }
  }
</script>

<style lang="less" scoped>
  @import "../../../assest/mixin";

  .issue-wrap {
    .wh(100%, 100%);
    .work-van {
      position: absolute;
      .wh(100%, auto);
      padding-bottom: 1.307rem;
      .empty-box {
        .fixed-auto(fixed);
        .wh(5.707rem, 5.707rem);
        .empty {
          .wh(100%, 100%)
        }
      }
    }
    .publish-box {
      position: fixed;
      bottom: 1.84rem;
      left: 0.32rem;
      .fj(center, center);
      flex-direction: column;
      .wh(1.6rem, 1.6rem);
      background: rgba(255, 143, 51, 1);
      .border-radius(50%);
      .publish-title {
        padding-top: 0.053rem;
        .size-color(0.293rem, rgba(255, 255, 255, 1));
        font-weight: 500;
      }
      .publish {
        padding-bottom: 0.053rem;
        .wh(0.533rem, 0.533rem);
      }
    }
  }
</style>
